<?php 
namespace Tools\Controller;
use Think\Controller;
/**
 * json的接口
 * @author HuHaiqin
 *
 */
class JsonController extends Controller{
	
	public function getjson(){
		if(!$_REQUEST['key']){
			_apiReturn(0, "miss param key");
		}
		
		$map['key'] = $_REQUEST['key'];		
		
		$data = M('Jsons')->where($map)->find();
		
		if($data){
			// 返回JSON数据格式到客户端 包含状态信息
			header('Content-Type:application/json; charset=utf-8');
			header("Access-Control-Allow-Origin: *");  //跨域请求
			exit($data['json']);
		}else{
			_apiReturn(0, 'sorry , can not find any json under this key!');//获取成功
		}
	}
}
?>